-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor: 인터셉터 리프레쉬 토큰 서버사이드 렌더링 코드 추가 #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: 인터셉터 리프레쉬 토큰 서버사이드 렌더링 코드 추가 #74
Conversation
|
@summerDev96 is attempting to deploy a commit to the 626-ju's projects Team on Vercel. A member of the Team first needs to authorize it. |
src/lib/cookie.ts
Outdated
|
|
||
| export function setServerCookie({ response, name, value, maxAge }: SetServerCookieParams) { | ||
| const cookie = `${name}=${encodeURIComponent(value)}; Path=/; Max-Age=${maxAge}; SameSite=Lax; Secure; HttpOnly`; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
테스트용 코드랑 전체적으로 큰 흐름은 비슷한 것 같습니다
함수를 어떻게 분리했는지 이런 세세한 것만 조금 다른 것 같아요
근데 여기서 httpOnly를 추가해서 보내버리면
겟 서버사이드 프롭스를 통해 이걸 사용한 페이지가 렌더 된 후
->
나중에 로그아웃할 때 로컬에서 강제로 쿠키에 접근해 삭제해야 할텐데 문제 없이 접근할 수 있나요???
저도 잘 모르겠어서 멘토님께 여쭤보고 피드백 받거나
직접 실험해봐야지 확실히 알 수 있을 거 같습니다.
그리고 SameSite =Lax
-> 이것도 다른 사이트에서 이미지를 가져올 때(get) 쿠키를 안보낸다고 하는데
-> 오늘 이미지 화면에 뿌려보니까 s3 아마존 어쩌구에서 받아서 오더라구요?
(sprint-fe-project.s3.ap-northeast-2.amazonaws.com)
이 경우에 안 걸리는지도 확인해봐야 할 것 같아요.
->만약 걸려서 요청이 제대로 안 보내진다면? none으로 설정해야 할텐데... 다른 방법이 있는지 여쭤보는 것도 좋을 것 같습니다
… refactor/interceptor
… refactor/interceptor
📦 Pull Request
📝 요약(Summary)
새로 브랜치를 생성하여 다시 PR 올렸습니다.
기존 PR 코드에서 수정된 부분들이 많아 다시 확인부탁드립니다!
쿠키를 저장하는 방식으로 변경되었습니다createApiClient함수에서context를 받아 인스턴스를 생성하게 수정하였습니다.리프레쉬 토큰 갱신관련 로직 서버사이드 렌더링시에도 공통적으로 적용되도록 추가하였습니다getServerSideProps로 유저 데이터 받아오는 것 테스트하였습니다. (/test/index.tsx)💬 공유사항 to 리뷰어
서버 사이드 렌더링 사용하시는 분들 머지 완료되시면 테스트 필요할 것 같습니다
환경변수 추가 필요
NEXT_PUBLIC_API_URL 추가 필요합니다.
클라이언트에서만 사용하는 api
기존 apiClient 그대로 두면 됩니다.
서버 사이드 렌더링 사용하는 api
createApiClient로 변경 필요합니다.
parameter로 context를 넘겨야 합니다.
🗂️ 관련 이슈
Refs #70
📸 스크린샷
✅ 체크리스트